package com.zbkj.crmeb.task.increment;

import com.utils.DateUtil;
import com.zbkj.crmeb.bargain.service.StoreBargainService;
import com.zbkj.crmeb.block.service.BlockService;
import com.zbkj.crmeb.task.bargain.BargainStopChangeTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Configuration //读取配置
@EnableScheduling // 2.开启定时任务
public class IncrementHistoryTask {
    //日志
    private static final Logger logger = LoggerFactory.getLogger(IncrementHistoryTask.class);

    @Autowired
    private BlockService blockService;

    @Scheduled(cron = "0 */5 * * * ?") //每天0点执行
    public void init() {
        logger.info("---IncrementHistoryTask------: Execution Time - {}", DateUtil.nowDateTime());
        try {
            blockService.saveIncrementEveryDay();
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("IncrementHistoryTask" + " | msg : " + e.getMessage());
        }

    }
}
